package org.example.springtest.model.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@JsonInclude(JsonInclude.Include.ALWAYS)
public record responseMessage<T>(Integer code, String message, T data) {

    public static <T> responseMessage<T> success(T data) {
        return new responseMessage<>(HttpStatus.OK.value(), "操作成功", data);
    }

    public static <T> responseMessage<T> error(Integer code, String message) {
        return new responseMessage<>(code, message, null);
    }

}
